<?php
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\model;

/**
 * 会员-模型
 * @author 牧羊人
 * @since 2020/11/15
 * Class Member
 * @package app\model
 */
class Member extends BaseModel
{
    // 设置数据表名
    protected $name = "member";

    /**
     * 获取会员信息
     * @param int $id 会员ID
     * @return 数据信息|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since 2020/11/15
     */
    public function getInfo($id)
    {
        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
        if ($info) {
            // 头像
            if ($info['avatar']) {
                $info['avatar'] = get_image_url($info['avatar']);
            }
            // 出生日期
            if ($info['birthday']) {
                $info['birthday'] = datetime($info['birthday']);
            }
            // 城市
            if ($info['province_id'] && $info['city_id'] && $info['district_id']) {
                $city = [];
                $city[] = $info['province_id'];
                $city[] = $info['city_id'];
                $city[] = $info['district_id'];
                $info['city'] = $city;
            }
        }
        return $info;
    }

}